package com.bkhech.boot.sample.swagger.service.event.impl;

import com.bkhech.boot.sample.swagger.mapper.event.EventLogMapper;
import com.bkhech.boot.sample.swagger.model.event.EventLog;
import com.bkhech.boot.sample.swagger.service.event.EventLogService;
import org.bkhech.mybatis.extend.generic.service.impl.GenericServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * ServiceImpl: EventLogServiceImpl
 * Mapper : EventLogMapper
 * Model  : EventLog
 *
 * This ServiceImpl generated by MyBatis Generator Extend at 2018-05-08 17:20:46
 */
 
@Service
@Transactional
public class EventLogServiceImpl extends GenericServiceImpl<EventLog, Integer, EventLogMapper> implements EventLogService {
    @Autowired
    private EventLogMapper eventLogMapper;

    @Override
    public EventLogMapper getGenericMapper() {
        return eventLogMapper;
    }

    @Override
    @Cacheable(value = "eventLog", key = "#p0")
    public EventLog getById(Integer id) {
        return getGenericMapper().selectByPrimaryKey(id);
    }

    @Override
    @CachePut(value = "eventLog", key = "#p0.id")
    public EventLog save(EventLog eventLog) {
        System.out.println("save  " + eventLog);
        this.insertSelective(eventLog);
        return eventLog;
    }
}